<div align="center"></div>
<div class="JO_left">
<script type="text/javascript" src="JO_JS/jquery.tokeninput.js"></script>
<link rel="stylesheet"		type="text/css"		href="JO_71_SO/token-input.css"					/>
	<!-- Form -->
<div
			class	= "JO_bar_720"
		>
			<h1><?= empty( $_REQUEST[ "SO_content_key" ] ) ? "Insert" : "Update" ?> a Content</h1>
			<div>
 				<span id="load_contend" > 
					loadding...
               </span>
	    </div>
		</div>
</div>
<div align="justify"> </div>
<div align="justify"> </div>
<script>
function showobj(url,obj) {
    document.getElementById(obj).innerHTML="<div style=\"height: 45px;text-align: center;width:100%;background: url(JO_80_image/loading4.gif) center no-repeat\"><br/>Loadding...</div>";
    if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest(); }
    else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
        xmlhttp.onreadystatechange=function() {
                if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    document.getElementById(obj).innerHTML=xmlhttp.responseText;
                }
           };
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
}
function searchKeyPress(e,f)
    {
        // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13)
        {
			var sea=escape(_utf8_encode($('#txt_id').val()));
			var sea2=escape(_utf8_encode($('#txt_music').val()));
			var sea3=escape(_utf8_encode($('#txt_tel').val()));
			var sea4=escape(_utf8_encode($('#txt_rbt').val()));
			var sea5=escape(_utf8_encode($('#txt_note').val()));
            if(sea=='' && sea2==''&& sea3==''&& sea4==''&& sea5=='' ){var url='JO_71_SO/SO_18_01_managing_RBT.php';}
            else{var url='JO_71_SO/SO_18_01_managing_RBT.php?';}
            
			if(sea!='')  {url+="&SO_sea="+sea;   }
			if(sea2!='') {url+="&SO_sea2="+sea2; }
			if(sea3!='') {url+="&SO_sea3="+sea3; }
			if(sea4!='') {url+="&SO_sea4="+sea4; }
			if(sea5!='') {url+="&SO_sea5="+sea5; }
		
				$("#load_contend").load(url,10000,function(){
					initbtnedit()
					initbtnadd()
				});
        }
    }
	function initbtnedit(){
		$(".btnedit").click(
				function (){
					if($("#tbp").length){
						$("#tbp").remove();
					}
					if($("#tmp").length){
						$("#tmp").remove();
					}
					var id=$($(this.parentNode).children("td:first")).html();
					$(this.parentNode).after("<tr ><td colspan=9 id=\"tmp\" style=\"padding:0 !important\">Loading...</td></tr>");
					var url="JO_71_SO/SO_18_02_managing_RBT.php?SO_chude="+id;
					$("#tmp").load(url,10000,function(){
					//initbtnedit();
					//initbtnadd();
					token();
				});
				}
			);
	}
	function initbtnadd(){
		$(".btnadd").click(
				function (){
					if($("#tmp").length){
						$("#tmp").remove();
					}
					if($("#tbp").length){
						$("#tbp").remove();
					}
					$(this.parentNode).after("<tr ><td colspan=8 id=\"tbp\" style=\"padding:0 !important\">Loading...</td></tr>");
					var url="JO_71_SO/SO_18_02_managing_RBT.php";
					$("#tbp").load(url,10000,function(){
					token();
					});
				}
			);
	}
$().ready(
	function(){
		var url="JO_71_SO/SO_18_01_managing_RBT.php";
		$("#load_contend").load(url,10000,function(){
			initbtnedit()
			initbtnadd()
		});
	}
);
	function tat(v){
		var code=$('#input').html();
		$('#input').html('<input  type="text\"  name=\"music\"  id=\"music\" value=\"<?=isset($row['music'])?$row['music']:""?>\"style=\"width:480px !important;\" onblur="hien(code)" />');
		token();
			hien(code);
	}
	function hien_add()
	{
		$('#token-input-music').blur(function(){
			var name =$('#music_name').val();
			$('#note').val(name);			 
		});	
	}
	function hien(code)
	{
		$('#token-input-music').blur(function(){
			if($('#boc').html()==null){					  
			$('#input').html(code);
			}
			var name =$('#music_name').val();
			$('#note').val(name);			 
		});	
	}
	function token(){
 $("#music").tokenInput("http://jukeon.vn/joii/JO_01_ajax_navigation.php?SO_controller=PublicController&active=rbtjson", {
							resultsFormatter: function(item){ return "<li>" +item.id +" |<b>Name</b>: "+ item.name +" |<b>Artist</b>: "+item.artist +" |<b>Album</b>: "+item.album+"</li><input type='hidden' value='"+item.name+"' id='music_name'>"} ,
							tokenFormatter: function(item) { return "<li><p id='boc'>" + item.id + " " + item.name + "</p></li><input type='hidden' value='"+item.name+"' id='music_name'>" },
							hintText: "Enter Music Key",
							searchDelay: 2000,
							minChars: 1,
							tokenLimit: 1
      					  });
	}
</script>